import multiprocessing


class MultiProcessQueued:
    def __init__(self, number_process, func, *args):
        self._number_process = number_process
        self._queue = multiprocessing.Queue()
        self._process_list = [multiprocessing.Process(target=func, args=(*args, self._queue)) for i in range(number_process)]

    def start(self):
        for p in self._process_list:
            p.start()
        for p in self._process_list:
            p.join()

    def results(self):
        ret = list()
        while not self._queue.empty():
            ret.append(self._queue.get())
        return ret
